package com.yk.mr.model.job;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
@Table(name = "job", schema = "cykmr", catalog = "")
public class JobModel {
    private String jobId;
    private String jobName;
    private String jobType;
    private Timestamp createTime;
    private Timestamp updateTime;
    private String submissionId;
    private String jarPath;
    private String jobInput;
    private String jobOutput;
    private String jobParameters;

    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Id
    @Column(name = "job_id", nullable = false, length = 255)
    public String getJobId() {
        return jobId;
    }

    public void setJobId(String jobId) {
        this.jobId = jobId;
    }

    @Basic
    @Column(name = "job_name", nullable = true, length = 255)
    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    @Basic
    @Column(name = "job_type", nullable = true, length = 255)
    public String getJobType() {
        return jobType;
    }

    public void setJobType(String jobType) {
        this.jobType = jobType;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "submission_id", nullable = true, length = 255)
    public String getSubmissionId() {
        return submissionId;
    }

    public void setSubmissionId(String submissionId) {
        this.submissionId = submissionId;
    }

    @Basic
    @Column(name = "jar_path", nullable = true, length = 255)
    public String getJarPath() {
        return jarPath;
    }

    public void setJarPath(String jarPath) {
        this.jarPath = jarPath;
    }

    @Basic
    @Column(name = "job_input", nullable = true, length = -1)
    public String getJobInput() {
        return jobInput;
    }

    public void setJobInput(String jobInput) {
        this.jobInput = jobInput;
    }

    @Basic
    @Column(name = "job_output", nullable = true, length = 255)
    public String getJobOutput() {
        return jobOutput;
    }

    public void setJobOutput(String jobOutput) {
        this.jobOutput = jobOutput;
    }

    @Basic
    @Column(name = "job_parameters", nullable = true, length = -1)
    public String getJobParameters() {
        return jobParameters;
    }

    public void setJobParameters(String jobParameters) {
        this.jobParameters = jobParameters;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        JobModel model = (JobModel) o;

        if (jobId != null ? !jobId.equals(model.jobId) : model.jobId != null) return false;
        if (jobName != null ? !jobName.equals(model.jobName) : model.jobName != null) return false;
        if (jobType != null ? !jobType.equals(model.jobType) : model.jobType != null) return false;
        if (createTime != null ? !createTime.equals(model.createTime) : model.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(model.updateTime) : model.updateTime != null) return false;
        if (submissionId != null ? !submissionId.equals(model.submissionId) : model.submissionId != null) return false;
        if (jarPath != null ? !jarPath.equals(model.jarPath) : model.jarPath != null) return false;
        if (jobInput != null ? !jobInput.equals(model.jobInput) : model.jobInput != null) return false;
        if (jobOutput != null ? !jobOutput.equals(model.jobOutput) : model.jobOutput != null) return false;
        if (jobParameters != null ? !jobParameters.equals(model.jobParameters) : model.jobParameters != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = jobId != null ? jobId.hashCode() : 0;
        result = 31 * result + (jobName != null ? jobName.hashCode() : 0);
        result = 31 * result + (jobType != null ? jobType.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (submissionId != null ? submissionId.hashCode() : 0);
        result = 31 * result + (jarPath != null ? jarPath.hashCode() : 0);
        result = 31 * result + (jobInput != null ? jobInput.hashCode() : 0);
        result = 31 * result + (jobOutput != null ? jobOutput.hashCode() : 0);
        result = 31 * result + (jobParameters != null ? jobParameters.hashCode() : 0);
        return result;
    }
}
